-
Notifications
You must be signed in to change notification settings - Fork 20
Fix: Resolve theme toggle FOUC issue on slow connections #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added critical inline CSS in BaseLayout.astro to style theme toggle immediately - Enhanced ThemeSwitcher skeleton state with proper sizing to prevent layout shift - Added id='theme-switcher-container' and 'theme-active' class for CSS targeting - Ensures theme toggle appears correctly sized from first paint - Prevents Flash of Unstyled Content (FOUC) on slow network connections - Includes comprehensive documentation in FOUC_FIX.md
|
Hi thanks for the PR, will check in a while |
| <div id="theme-switcher-container" className="grid grid-cols-1"> | ||
| <div className="relative z-0 inline-grid grid-cols-2 gap-0.5 rounded-full bg-gray-950/5 p-0.5 sm:p-0.75 text-gray-950 dark:bg-white/10 dark:text-white"> | ||
| <div className="relative rounded-full p-0.5 sm:p-1 lg:p-1 theme-active"> | ||
| <svg viewBox="0 0 28 28" fill="none" className="size-4 sm:size-5 lg:size-6"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is hardcoding the svg in file required? We have many lucide icons,
if its absolutely required, pls put it in public dir and use its url
<img src="/freedevtools/svg_icons/comet/moon.svg">
Ex: https://hexmos.com/freedevtools/svg_icons/comet/moon.svg
FOUC_FIX.md
Outdated
| The dark mode/light mode theme toggle button appeared large and unstyled during initial page load on slow network connections, causing a "Flash of Unstyled Content" (FOUC). | ||
|
|
||
| ## Root Cause | ||
| The theme toggle button was rendering before the main CSS stylesheet (`global.css`) loaded. This caused the SVG icons to display at their default size without proper styling, creating a jarring visual experience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls add the description in PR itself and rm this file.
#38
Theme Toggle FOUC Fix
Problem
The dark mode/light mode theme toggle button appeared large and unstyled during initial page load on slow network connections, causing a "Flash of Unstyled Content" (FOUC).
Root Cause
The theme toggle button was rendering before the main CSS stylesheet (
global.css) loaded. This caused the SVG icons to display at their default size without proper styling, creating a jarring visual experience.